package ldwu.spark.mytest

import org.apache.log4j.{Level, Logger}
import scopt.OptionParser

object test_parser {
  def main(args: Array[String]): Unit = {
    case class Params(
       input: String = null,
       kryo: Boolean = false,
       rank: Int = 10
       )

    val dd = Params()
    println(s"hello world miao~~ ${dd.rank}")
    val parser = new OptionParser[Params]("MovieLensALS") {
      opt[Int]("rank")
        .text(s"rank, default: ${dd.rank}}")
        .action((x, c) => c.copy(rank = x))
    }
    parser.parse(args, dd).map { params =>
      hello(params)
    } getOrElse {
      System.exit(1)
    }
    def hello(params: Params): Unit = {
      println(s"MovieLensALS with $params")
      println(params.rank)
    }
  }
}
